'use strict';
/**
 * @bussiness {搜索}
 * @author {JC}
 * @date {2022-09-28}
 * **/
const Service = require('egg').Service;
class Search extends Service {
    /**@effect {拿取搜素匹配信息数据}**/
    async takeSearchList(params) {
        const { app } = this;
        const { keywords, limit, offset } = params;
        const resUsers = await app.mysql.select('users', { // 用户
            where: { user_name: keywords },
            limit: limit, offset: offset
        });
        const resGoods = await app.mysql.select('goods', { // 商品
            where: { goods_tags: keywords },
            limit: limit, offset: offset
        })
        // 拿取到的数据进行分类展示
        return [{ user: [...resUsers] }, { goods: [...resGoods] }]
    }
}
module.exports = Search